package com.yq.spbYq.mapper;

import com.yq.spbYq.Reward;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RewardMapper {

    // 查询所有奖励物品
    @Select("SELECT * FROM reward")
    @Results({
            @Result(property = "rewardId", column = "reward_id"),
            @Result(property = "rewardName", column = "reward_name"),
            @Result(property = "rewardDescription", column = "reward_description"),
            @Result(property = "requiredPoints", column = "required_points")
    })
    List<Reward> selectAllRewards();

    // 根据ID查询奖励物品
    @Select("SELECT * FROM reward WHERE reward_id = #{rewardId}")
    @Results({
            @Result(property = "rewardId", column = "reward_id"),
            @Result(property = "rewardName", column = "reward_name"),
            @Result(property = "rewardDescription", column = "reward_description"),
            @Result(property = "requiredPoints", column = "required_points")
    })
    Reward selectRewardById(Integer rewardId);

    // 新增奖励物品
    @Insert("INSERT INTO reward(reward_name, reward_description, required_points) VALUES(#{rewardName}, #{rewardDescription}, #{requiredPoints})")
    int insertReward(Reward reward);

    // 更新奖励物品
    @Update("UPDATE reward SET reward_name = #{rewardName}, reward_description = #{rewardDescription}, required_points = #{requiredPoints} WHERE reward_id = #{rewardId}")
    int updateReward(Reward reward);

    // 根据ID删除奖励物品
    @Delete("DELETE FROM reward WHERE reward_id = #{rewardId}")
    int deleteRewardById(Integer rewardId);
}